package cc.xulu.controller;

import com.jfinal.core.Controller;

import cc.xulu.model.*;

public class PostTagController extends Controller {
	public void index() {
		setAttr("post_tagPage", PostTag.dao.paginate(getParaToInt(0, 1), 10, "select *", "from post_tag order by id asc"));
		render("list.html");
	}
	
	public void add() {
	    render("edit.html");
	}
	
	public void save() {
		PostTag post_tag = getModel(PostTag.class);
		if (post_tag.get("id") == null) {
			post_tag.save();
		} else {
			post_tag.update();
		}
		redirect("/post_tag");
	}
	
	public void edit() {
		setAttr("post_tag", PostTag.dao.findById(getParaToInt()));
		render("edit.html");
	}
	
	public void update() {
		getModel(PostTag.class).update();
		redirect("/post_tag");
	}
	
	public void delete() {
		PostTag.dao.deleteById(getParaToInt());
		redirect("/post_tag");
	}
}
